﻿using Prism.Commands;
using Prism.Mvvm;
using Prism.Services.Dialogs;
using System;

namespace CCSSolderUI.ViewModels.Dialogs
{
    public class PasswordDialogViewModel : BindableBase, IDialogAware
    {
        public string Title => "请输入密码";

        public event Action<IDialogResult> RequestClose;
        private string password = "";
        public string Password
        {
            get { return password; }
            set { SetProperty(ref password, value); }
        }
        private DelegateCommand<object> passwordOperateCommad;
        public DelegateCommand<object> PasswordOperateCommad =>
            passwordOperateCommad ?? (passwordOperateCommad = new DelegateCommand<object>(ExecutePasswordOperateCommad));

        void ExecutePasswordOperateCommad(object obj)
        {
            switch (obj.ToString())
            {
                case "确认":
                    DialogParameters param = new DialogParameters();
                    param.Add("Password", Password);
                    RequestClose?.Invoke(new DialogResult(ButtonResult.Yes, param));
                    break;
                case "取消":
                    RequestClose?.Invoke(new DialogResult(ButtonResult.None));
                    break;
                default:
                    break;
            }
        }
        public bool CanCloseDialog()
        {
            return true;
        }

        public void OnDialogClosed()
        {
            
        }

        public void OnDialogOpened(IDialogParameters parameters)
        {
            
        }
    }
}
